/*
 * @Description: 
 * @Version: 2.0
 * @Autor: GUOCHAO82
 * @Date: 2021-09-08 17:28:39
 * @LastEditors: GUOCHAO82
 * @LastEditTime: 2022-06-15 14:12:37
 */
import {nodeResolve} from "@rollup/plugin-node-resolve";
import babel from "rollup-plugin-babel";
import { terser } from 'rollup-plugin-terser';
import { eslint } from 'rollup-plugin-eslint';
import ts from 'rollup-plugin-typescript2'
import copy from 'rollup-plugin-copy'
export default {
  input: ["./src/index.ts"],
  // input: ["./src/text.ts"],

  output: {
    // global: 弄个全局变量来接收
    // cjs: module.exports
    // esm: export default
    // iife: ()()
    // umd: 兼容 amd + commonjs 不支持es6导入
    file: "./threeSdk/dist/index.js",
    format: "esm",
    sourcemap: false,
    name: "threeSdk",
  },
  external:[
    'three',
    'three/examples/jsm/renderers/CSS3DRenderer',
    'three/examples/jsm/postprocessing/OutlinePass',
    'three/examples/jsm/postprocessing/EffectComposer',
    'three/examples/jsm/postprocessing/RenderPass',
    'three/examples/jsm/postprocessing/ShaderPass',
    'three/examples/jsm/shaders/FXAAShader',
    'three/examples/jsm/loaders/OBJLoader',
  ],
  plugins: [
      nodeResolve(),
      ts({
        useTsconfigDeclarationDir:true,
      }),
      eslint({
        include:['./threeSdk']
      }),
      babel(),
      terser(),
      copy({
        targets:[
          {
            src:'./package.json',
            dest:'./threeSdk',
            transform: (contents, filename) =>{
              return contents.toString().replace(/"devDependencies[\w,\s,\S]+},/, '')
            }
          },
          {
            src:'./src/type.d.ts',
            dest:'./threeSdk/types'
          },
          {
            src:'./.gitignore',
            dest:'./threeSdk'
          }
        ]
      })
    ],
};